package com.yupi.springbootinit.bizmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import net.sf.jsqlparser.expression.operators.arithmetic.Concat;

public class MqInitMain {

    public static void main(String[] args) {

        try{
            ConnectionFactory factory=new ConnectionFactory();
            factory.setHost("localhost");
            factory.setPort(5672);
            //设置账号信息，用户名，密码，vhost
            factory.setVirtualHost("testhost");
            factory.setUsername("admin");
            factory.setPassword("123456");
            Connection connection=factory.newConnection();
            Channel channel= connection.createChannel();

            String EXCHANGE_NAME="code_exchange";
            channel.exchangeDeclare(EXCHANGE_NAME,"direct");

            String queueName="code_queue";
            channel.queueDeclare(queueName,true,false,false,null);
            channel.queueBind(queueName,EXCHANGE_NAME,"my_routingKey");

        }catch (Exception e){

        }
    }
}
